/**
 * 总资源 类
 * resourceId           : 资源标号
 * totalInstances       : 总实例数
 * availableInstances   : 可用实例数
 */
public class ResourceType {

    private final int resourceId;
    private final int totalInstances;
    private int availableInstances;

    public ResourceType(int resourceId, int totalInstances) {
        this.resourceId = resourceId;
        this.totalInstances = totalInstances;
        this.availableInstances = totalInstances;
    }

    public int getResourceId() {
        return resourceId;
    }

    public int getTotalInstances() {
        return totalInstances;
    }

    public int getAvailableInstances() {
        return availableInstances;
    }

    public void setAvailableInstances(int availableInstances) {
        this.availableInstances = availableInstances;
    }

    @Override
    public String toString() {
        return String.format("R%d[总:%d, 可用:%d]",
                resourceId, totalInstances, availableInstances);
    }
}
